package com.lizard.schedule.utils;

import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Environment;

import java.io.File;

/**
 * 文件相关工具类
 */
public class FileUtil {

    /**
     * 检查是否存在SD卡
     * @return
     */
    public static boolean isSdCardExist(){
        return Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED);
    }

    /**
     * 获取SD卡根目录
     * @return
     */
    public static File getSdPath(){
        return Environment.getExternalStorageDirectory();
    }

    /**
     * 获取apk文件的PackageInfo值
     *
     * @param context
     * @param apkFilePath
     * @return
     */
    public static PackageInfo getApkFilePackageInfo(Context context, String apkFilePath){
        PackageManager packageManager = context.getPackageManager();
        return packageManager.getPackageArchiveInfo(apkFilePath, PackageManager.GET_ACTIVITIES);
    }
}
